package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.GoodsInfoDao;
import com.coolbi.onsupai.core.entity.GoodsInfo;
import com.coolbi.onsupai.core.mapper.GoodsInfoMapper;

public class GoodsInfoDaoImpl implements GoodsInfoDao {
	
	@Autowired
	private GoodsInfoMapper goodsInfoMapper;
	
	public void setGoodsInfoMapper(GoodsInfoMapper goodsInfoMapper) {
		this.goodsInfoMapper = goodsInfoMapper;
	}

	@Override
	public GoodsInfo save(GoodsInfo obj) {
		goodsInfoMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return goodsInfoMapper.delete(id);
	}

	@Override
	public int update(GoodsInfo obj) {
		return goodsInfoMapper.update(obj);
	}

	@Override
	public GoodsInfo get(long id) {
		return goodsInfoMapper.get(id);
	}

	@Override
	public List<GoodsInfo> list() {
		return goodsInfoMapper.list();
	}

	@Override
	public List<GoodsInfo> listByPage(int offset, int limit) {
		Map<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return goodsInfoMapper.listByPage(parameter);
	}

	@Override
	public List<GoodsInfo> find(Map<String, Object> parameter) {
		return goodsInfoMapper.listByParameter(parameter);
	}

	@Override
	public List<GoodsInfo> findByPage(Map<String, Object> parameter,
			int offset, int limit) {
		return goodsInfoMapper.listByParameterPage(parameter);
	}

	@Override
	public List<GoodsInfo> search(Map<String, Object> parameter, int offset,
			int limit) {
		return goodsInfoMapper.search(parameter);
	}

	@Override
	public int count() {
		return goodsInfoMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return goodsInfoMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return goodsInfoMapper.countByParameter(parameter);
	}

	@Override
	public int countByGoodsNo(String goodsNo) {
		return goodsInfoMapper.countByGoodsNo(goodsNo);
	}

	@Override
	public int updateByBatch(List<GoodsInfo> goodsInfos) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("goodsInfos", goodsInfos);
		return goodsInfoMapper.updateByBatch(parameter);
	}

	@Override
	public List<GoodsInfo> findByIds(List<Long> ids) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("ids", ids);
		return goodsInfoMapper.findByIds(parameter);
	}
}
